// 管理员登录接口
const express = require('express');
const router = express.Router();
const db = require('../../db/connect');
const xzid = require('xzid');
const dayjs = require("dayjs");

router.post('/admin/addStudent', (req, res) => {
    const { student_id,build,card,email,floor,name,password,profession,room,school_id,sex,tel,type,room_id,floor_id ,build_id} = req.body;
    console.log(student_id,build,card,email,floor,name,password,profession,room,school_id,sex,tel,type,room_id,floor_id ,build_id)
    const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
    const sql = `INSERT INTO manger_student (student_id,username,password,tel,
        studentcard,build,type,school_id,sex,profession,floor,room,time,email,room_id,floor_id,build_id) VALUES
     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
    `;
    db(sql, [student_id, name, password,tel,card,build,type,school_id ,sex,profession,floor,room,now,email,room_id,floor_id,build_id], (err, data) => {
        if (data.affectedRows !== 0) {
            res.send({
                data,
                code: 200
            })
        } else {
            res.send({
                code: 400,
                content: err,
                message: '告诉他账户不存在'
            })
        }
    })
})
module.exports = router